<template>
	<view>
		<view class="anchorHomepage connaught-style" id="app">
		    <image style="width: 100%;height: 250rpx;" src="https://m.nocexpo.com/statics/js/modules/h5/img/img9.jpg" class="banner"/>
		    <view class="anchor-module ">
		        <view class="anchor-info" style="display: flex;">
		            <view class="info">
		                <image class="avatar"
		                     :src="userInfo.portrait?userInfo.portrait:'https://m.nocexpo.com/statics/js/modules/h5/img/wutouxiang.png'"/>
		                <view class="name-grey">
		                    <view class="h4" style="text-overflow: ellipsis;max-width: 210rpx;white-space:nowrap;overflow: hidden;">{{userInfo.userName}}</view>
		                    <view class="p" style="text-overflow: ellipsis;max-width: 210rpx;white-space:nowrap;overflow: hidden;"><image src="https://m.nocexpo.com/statics/js/modules/h5/img/Certification.png"/>{{userInfo.company}}
		                    </view>
		                </view>
		            </view>
		            <view class="enterComp" style="background: #029e9d" @click="enterComp"
		                 v-if="userInfo.type==1 && userInfo.state==1">
		                <image src="https://m.nocexpo.com/statics/js/modules/h5/img/img33.png"/>进入展厅
		            </view>
		
		            <view class="block" v-if="currentUser.id!=userInfo.id">
		                <view  class="btn button" @click="attention" v-if="attentionFlag"><view class="span">+</view>关注</view>
		                <view class="btn_a button" @click="attention" v-else><view class="span"></view>已关注</view>
		            </view>
		            <view class="private-letters"
		                 style="flex-shrink: 0;display: flex;justify-content: space-between;align-items: center;flex-wrap: wrap;" v-if="currentUser.id!=userInfo.id">
		                <view class="btn-email" @click="sendMsg(userInfo.id)"
		                     style="background-color: #FF9600;line-height: 46rpx;border-radius: 23rpx;color: #ffffff;padding: 0px 21rpx;font-size: 10px;">
		                    <image src="https://m.nocexpo.com/statics/js/modules/h5/img/icon_email.png"
		                         style="width: 28rpx;vertical-align: middle;margin-right: 7rpx;margin-top: -4rpx;height: 22rpx;"/>私信
		                </view>
		            </view>
		            <view class="private-letters"
		                 style="flex-shrink: 0; display: flex; justify-content: space-between;align-items: center;flex-wrap: wrap;"
		                 v-if="currentUser.id==userInfo.id" @click="editMsg()">
		                <view class="btn-email" personalInformation
		                     style="background-color: #029e9d;line-height: 46rpx;border-radius: 23rpx;color: #ffffff;padding: 0px 21rpx;font-size: 21rpx;">
		                    编辑
		                </view>
		            </view>
		        </view>
		        <view v-if="userInfo.personSign" style="margin-top: 14rpx; font-size: 25rpx;">
		            {{userInfo.personSign}}
		        </view>
		        <view v-else style="margin-top: 14rpx; font-size: 25rpx; color: #b0b2bf;">
		            填写个性签名更容易获得关注！
		        </view>
		        <view class="anchor-total" style="display: flex;justify-content: space-between;align-items: center;flex-wrap: wrap;">
		            <view @click="myfan" class="div">
		                <view class="h3">{{userInfo.fansCount}}</view>
		                <view class="p">粉丝</view>
		            </view>
		            <view @click="myAttention" class="div">
		                <view class="h3">{{userInfo.attentionCount}}</view>
		                <view class="p">关注</view>
		            </view>
		            <view class="div">
		                <view class="h3" >{{userInfo.videoBytagsCount}}</view>
		                <view class="p">获赞</view>
		            </view>
		        </view>
		    </view>
		    <view class="tabs" style="position: -webkit-sticky;position: sticky;top:0;z-index: 99;display: flex;">
		        <view class=" item" :class="[index==1?'active':'']" @click="tabsClick(1)">
					<view style="display: flex;position: absolute;left: 33%;">
						小视频
						<view class="strong">{{'（'+searchVideo.totalCount+'）'}}</view>
					</view>
					<view class="span"></view>
					
		        </view>
		        <view class=" item" :class="[index==3?'active':'']" @click="tabsClick(3)">
					<view style="display: flex;position: absolute;left: 33%;">
						动态
						<view class="strong">{{'（'+newsSearch.totalCount+'）'}}</view>
					</view>
						<view class="span"></view>
		        </view>
		        <view class=" item" :class="[index==2?'active':'']" @click="tabsClick(2)">
					<view style="display: flex;position: absolute;left: 33%;">
						喜欢
						<view class="strong">{{'（'+connectVideo.totalCount+'）'}}</view>
					</view>
						<view class="span"></view>
		        </view>
		    </view>
		    <view class="sp-module" v-if="index==1">
		        <view class="item" v-for="(item,index) in videoList" @click="toVideoMain(item.id)">
		            <view class="item-image">
		                <image :src="item.coverImg?item.coverImg:(item.videoUrl+'?x-oss-process=video/snapshot,t_7000,f_jpg,m_fast')"/>
		
		                <view class="date">{{item.videoDuration}}</view>
		            </view>
		            <view class="item-title">{{item.videoTitle}}</view>
		            <!--<view class="play-comment">
		                <view><image src="https://m.nocexpo.com/statics/js/modules/h5/img/icon105.png">{{item.browseCount}}</view>
		                <view><image src="https://m.nocexpo.com/statics/js/modules/h5/img/icon104.png">{{item.commentCount}}</view>
		            </view>-->
		            <view class="play-comment1">
		                <view style="font-size: 12px;width: 60%;float: left">
		                    <image :src="item.author.portrait?item.author.portrait:'https://m.nocexpo.com/statics/js/modules/h5/img/wutouxiang.png'"
		                         style="border-radius: 50%"/>{{item.author.userName}}
		                </view>
		                <view v-if="item.like == null"
		                     style="font-size: 12px;width: 20%;text-align: right;float: right;margin-right: 14rpx">
		                    <image src="https://m.nocexpo.com/statics/js/modules/h5/img/zan0.png"
		                         @click.stop="giveVideoLike(item.id,index)"/>{{item.likeCount}}
		                </view>
		                <view v-else
		                     style="font-size: 12px;width: 20%;text-align: right;float: right;margin-right: 14rpx">
		                    <image src="https://m.nocexpo.com/statics/js/modules/h5/img/zan1.png"
		                         @click.stop="cancelVideoLike(item.like,index)"/>{{item.likeCount}}
		                </view>
		            </view>
		        </view>
		        <view class="hint" v-show="noMoreVideo">我是有底线的</view>
		        <view class="hint" v-show="loadingVideo">加载中...</view>
		        <view class="hint" v-show="noDataVideo">暂未上传视频</view>
		    </view>
		    <view class="sp-module" v-else-if="index==2">
		        <!--<view v-html="decodeURIComponent(userInfo.details?userInfo.details:'暂无')"></view>-->
		        <view class="item" v-for="item in connectList" @click="toVideoMain(item.id)">
		            <view class="item-image">
		                <image :src="item.coverImg?item.coverImg:(item.videoUrl+'?x-oss-process=video/snapshot,t_7000,f_jpg,m_fast')"/>
		
		                <view class="date">{{item.videoDuration}}</view>
		            </view>
		            <view class="item-title">{{item.videoTitle}}</view>
		            <view class="play-comment">
		                <view><image src="https://m.nocexpo.com/statics/js/modules/h5/img/icon105.png"/>{{item.browseCount}}</view>
		                <view><image src="https://m.nocexpo.com/statics/js/modules/h5/img/icon104.png"/>{{item.commentCount}}</view>
		            </view>
		        </view>
		        <view class="hint" v-show="noMoreVideo">我是有底线的</view>
		        <view class="hint" v-show="loadingVideo">加载中...</view>
		        <view class="hint" v-show="noDataVideo">暂未上传视频</view>
		    </view>
		    <view v-else-if="index==3">
		        <view v-if="newsList1.length>0" >
		            <view id="fall-list">
		                <view id="newsList1" class="fall-line">
		                    <view class="fall-item" style="margin: 5px 3px 5px 5px;" v-for="(item, index) in newsList1" :key="index">
		                        <view class="a" @click="goNewsDet(item.id)">
		                            <view style="max-height: 230px;overflow: hidden">
		                                <image style="width: 100%;" mode="widthFix" :src="item.pictureUrl"/>
		                            </view>
		                            <view class="item-title1">{{item.title}}
		                            </view>
		                        </view>
		                        <view class="play-comment1">
		                            <view style="font-size: 12px;width: 40%;float: left">
		                                <image :src="item.author.portrait?item.author.portrait:'https://m.nocexpo.com/statics/js/modules/h5/img/wutouxiang.png'" style="border-radius: 50%"/>{{item.author.userName}}
		                            </view>
		                            <view v-if="item.like == 0" style="font-size: 12px;width: 40%;text-align: right;float: right;margin-right: 14rpx">
		                                <image src="https://m.nocexpo.com/statics/js/modules/h5/img/zan0.png" @click="giveLike(item.id,index,1)"/>{{item.likeCount}}
		                            </view>
		                            <view v-else="item.like == 1" style="font-size: 12px;width: 40%;text-align: right;float: right;margin-right: 14rpx">
		                                <image src="https://m.nocexpo.com/statics/js/modules/h5/img/zan1.png" @click="cancelLike(index,item.collectId,1)"/>{{item.likeCount}}
		                            </view>
		                        </view>
		                    </view>
		                </view>
		                <view id="newsList2" class="fall-line">
		                    <view class="fall-item" style="margin: 5px 5px 5px 2px;" v-for="(item, index) in newsList2" :key="index">
		                        <view class="a" @click="goNewsDet(item.id)">
		                            <view style="max-height: 230px;overflow: hidden">
		                                <image style="width: 100%;" mode="widthFix" :src="item.pictureUrl"/>
		                            </view>
		                            <view class="item-title1">{{item.title}}
		                            </view>
		                        </view>
		                        <view class="play-comment1">
		                            <view style="font-size: 12px;width: 40%;float: left">
		                                <image :src="item.author.portrait?item.author.portrait:'https://m.nocexpo.com/statics/js/modules/h5/img/wutouxiang.png'" style="border-radius: 50%"/>{{item.author.userName}}
		                            </view>
		                            <view v-if="item.like == 0" style="font-size: 12px;width: 40%;text-align: right;float: right;margin-right: 14rpx">
		                                <image src="https://m.nocexpo.com/statics/js/modules/h5/img/zan0.png" @click="giveLike(item.id,index,2)"/>{{item.likeCount}}
		                            </view>
		                            <view v-else="item.like == 1" style="font-size: 12px;width: 40%;text-align: right;float: right;margin-right: 14rpx">
		                                <image src="https://m.nocexpo.com/statics/js/modules/h5/img/zan1.png" @click="cancelLike(index,item.collectId,2)"/>{{item.likeCount}}
		                            </view>
		                        </view>
		                    </view>
		                </view>
		            </view>
		            <view class="hint" style="display: inline-block" v-show="newsSearch.loading">加载中...</view>
		            <view class="hint" style="display: inline-block" v-show="newsSearch.noMore">我是有底线的</view>
		        </view>
		        <view v-else style="margin-left: 70rpx;">暂无资讯</view>
		    </view>
		</view>
	</view>
</template>

<script>
import anchorApi from '@/api/anchorHomepage.js';
import commonApi from '@/utils/commonMethod.js';

export default {
	
	data() {
		return {
			index: 3, //tabs切换
			userId:'',//用户id
			userInfo:'',//个人信息
			loadingVideo: false,//正在加载
			noMoreVideo: false,//没有更多数据
			noDataVideo: false,//没有数据
			searchVideo: {
				page: 1,
				limit: 10,
				search: '',
				lastpage: 0,
				totalPage: '',
				userId:'',
				totalCount: ''
			},//视频查询
			videoList:[],//创作视频

			loadingConnect: false,//正在加载
			noMoreConnect: false,//没有更多数据
			noDataConnect: false,//没有数据
			connectVideo: {
				page: 1,
				limit: 10,
				search: '',
				lastpage: 0,
				totalPage: '',
				userId:'',
				totalCount: ''
			},//收藏的视频
			connectList: [], //收藏列表

			currentUser:'',//当前用户
			attentionFlag:true,//是否关注该作者
			newsSearch: {
				page: 1,
				limit: 10,
				totalPage: '',
				totalCount: '',
				userId:'',
				loading: false,
				noMore: false,
			},
			newsList: [],
			newsList1: [],
			newsList2: [],
			newsHeight1:0,
			newsHeight2:0,
			
			startTime:'', //进入页面时间
			endTime:'',//离开页面时间
			currentUrl:'',//当前页面全路径

		}
	},
	async onLoad(options){
		const self = this;
		
		//获取当前用户
		const currentUserValue = await commonApi.currentUserAxios();
		self.currentUser = currentUserValue.data.session_user_h5;
		self.userId = options.userId;
		self.searchVideo.userId = options.userId;
		self.connectVideo.userId = options.userId;
		self.newsSearch.userId = options.userId;
		self.getUserInfo();
		

		//不是页面回退
		// if (window.performance && window.performance.navigation.type != 2) {
		// 	let browsFlag  = sessionStorage.getItem('browsFlag');
		// 	let index = sessionStorage.getItem('index');
		// 	if(!index && browsFlag == null){
		// 		sessionStorage.clear();
		// 	}
	
		await self.getCreateVideo();
		await self.getConnectVideo();
		await self.getNewsList();
		
		const pages = getCurrentPages()
		const currentPage =pages[pages.length - 1]
		this.currentUrl = currentPage.$page.fullPath

		// 	//从个人主页进入其他展厅/主页出现session覆盖，页面回退session取值数据出错，故携带标志，有则刷新页面
		// 	let p = options.flag
		// 	if('anchorHomepage' == p){
		// 		sessionStorage.setItem('refreshFlag', 'refreshFlag');
		// 	}
		// }else{//页面回退
		// 	let refreshFlag = sessionStorage.getItem('refreshFlag');
		// 	if('refreshFlag' == refreshFlag){
		// 		window.location.reload();
		// 	}
		// 	this.index = JSON.parse(sessionStorage.getItem('active_index'));
		// 	this.videoList = JSON.parse(sessionStorage.getItem('videoList'));
		// 	this.searchVideo = JSON.parse(sessionStorage.getItem('searchVideo'));
		// 	this.connectList = JSON.parse(sessionStorage.getItem('connectList'));
		// 	this.connectVideo = JSON.parse(sessionStorage.getItem('connectVideo'));
		// 	this.newsList1 = JSON.parse(sessionStorage.getItem('newsList1'));
		// 	this.newsList2 = JSON.parse(sessionStorage.getItem('newsList2'));
		// 	this.newsSearch = JSON.parse(sessionStorage.getItem('newsSearch'));
		// 	if(null == this.newsList1){
		// 		// window.location.reload();
		// 		this.onLoad()
		// 	}
		// }

		// $(window).scroll(function () {
		// 	let scrollTop = $(this).scrollTop();
		// 	let windowHeight = $(this).height();
		// 	let scrollHeight = $(document).height();

		// 	if (scrollTop + windowHeight > scrollHeight - 1) {
		// 		//判断当前是直播还是视频,如果是直播则进行直播的查询,如果是视频则进行视频的查询
				if (self.index == 1) {
					//当前是视频模块
					if (self.searchVideo.page < self.searchVideo.totalPage) {
						//当前不是最后一页
						self.loadingVideo = true;
						self.searchVideo.page++;
						self.getCreateVideo()
					} else {
						self.noMoreVideo = true
					}
				}else if(self.index == 2){
					//收藏
					if (self.connectVideo.page < self.connectVideo.totalPage) {
						//当前不是最后一页
						self.loadingConnect = true;
						self.connectVideo.page++;
						self.getConnectVideo();
					} else {
						self.noMoreConnect = true
					}
				}else if(self.index == 3){
					if (self.newsSearch.page < self.newsSearch.totalPage) {
						self.newsSearch.page++;
						self.newsSearch.loading = true;
						self.getNewsList()
					} else {
						self.newsSearch.noMore = true;
						self.newsSearch.loading = false;
					}

				}
		// 	}
		// });

	},
	onShow(){
	  
	  setTimeout(()=> {
	    
	    if (getApp().globalData.onShow) {
	      getApp().globalData.onShow = 0;
	      console.log("demo前后台切换之切到前台")
	    }
	    else {
	      console.log("demo页面被切换显示")
	      this.startTime = +new Date();
	    }
	    
	  }, 100);
	},
	onHide(){
	  setTimeout(() => {
	    var that = this
	    if (getApp().globalData.onHide) {
	      getApp().globalData.onHide = 0;
	      console.log("还在当前页面活动")
	    }
	    else {
	      that.endTime = +new Date();
	      console.log("demo页面停留时间：" + (that.endTime - that.startTime))
	      var stayTime = Math.round((that.endTime - that.startTime)/1000);
	       //这里获取到页面停留时间stayTime，然后了可以上报了
	       this.saveFootPrint(stayTime);
	    }
	  }, 100)
	},
	onUnload(){
	    setTimeout(() => {
	    var that = this
	    if (getApp().globalData.onHide) {
	      getApp().globalData.onHide = 0;
	      console.log("还在当前页面活动")
	    }
	    else {
	      that.endTime = +new Date();
	      console.log("demo页面停留时间：" + (that.endTime - that.startTime))
	      var stayTime = Math.round((that.endTime - that.startTime)/1000);
	       //这里获取到页面停留时间stayTime，然后了可以上报了
	       this.saveFootPrint(stayTime);
	    }
	  }, 100)
	},
	methods: {
		saveFootPrint(stayTime){
		    commonApi.saveFootPrint(this.currentUser.id,this.startTime,stayTime,this.currentUrl,"个人主页")
		        
		},
		/**
		 * 判断用户是否登陆
		 */
		async ifLogin(){
			
			this.register = await commonApi.getUserLoginFlag();
			if (this.register) {
			  // 跳转登录
			  uni.redirectTo({
			    url: '/pages/account/login/login'
			  })
			  return;
			}
			
		},
		/**
		 *  进入个人展厅
		 */
		enterComp() {
			uni.navigateTo({
				url:'/pages/product/showroom/showroom?userId=' + this.userId
			})
			// window.location.href = '/h5/cloudcomp.html?userId=' + this.userInfo.id;
		},
		/**
		 * 获取个人主页信息
		 */
		getUserInfo(){
			const self = this;
			anchorApi.getUserInfo(this.userId).then(res=>{
			   if(res.data.code == 0){
				   self.userInfo = res.data.user
				   if (self.userInfo.attentionAuthor) {
					   self.attentionFlag = false
				   }
			   }
			})
		},
		/**
		 * 发送私信
		 * @param id
		 * @returns {Promise<void>}
		 */
		async sendMsg(id) {
			// this.register = await commonApi.getUserLoginFlag();
			// if (this.register) {
			//   // 跳转登录
			//   uni.redirectTo({
			//     url: '/pages/account/login/login'
			//   })
			//   return;
			// }
			
			const result = await commonApi.judgeIfPhone()
			if (!result) {
				return
			}
			uni.navigateTo({
				url: '/pages/news/chatDetail/chatDetail?toUserId=' + this.userId +'&sixin=siXin',
			})
		},
		/**
		 * 获取创作的视频
		 */
		getCreateVideo(){
			const self = this
			
			anchorApi.getCreateVideo(self.searchVideo).then((res) => {
				console.log("this.video");
				console.log(res);
				self.loadingVideo = false
				self.searchVideo.totalPage = res.data.page.totalPage;
				self.searchVideo.totalCount = res.data.page.totalCount;
				self.searchVideo.page = res.data.page.currPage
				if (self.searchVideo.page == self.searchVideo.totalPage) {
					self.noMoreVideo = true
				}
				self.videoList = [...self.videoList, ...res.data.page.list];
				self.videoList.forEach((value, index, array) => {
					if (value.videoDuration) {
						value.videoDuration = value.videoDuration.slice(-8)
					}
				})
				// sessionStorage.setItem("videoList", JSON.stringify(self.videoList));
				// sessionStorage.setItem("searchVideo", JSON.stringify(self.searchVideo));
			})
		},
		//关注/取关作者
		attention() {
			const self = this;
			self.ifLogin();
			anchorApi.attention(self.userId.toString(),self.attentionFlag).then(res => {
				if (res.data.code === 0) {
					self.attentionFlag = !self.attentionFlag;
					if(self.attentionFlag){
						self.userInfo.fansCount--
					}else{
						self.userInfo.fansCount++
					}

				}
			})
		},
		toVideoMain(id) {
			// sessionStorage.setItem("active_index", this.index);
			uni.navigateTo({
				url:'/pages/product/vidoDetail/vidoDetail?id='+ id
			})
			// window.location.href = "/h5/video/videoMain.html?id=" + id;
		},
		tabsClick(e) {
			this.index = e;
		},
		myfan(){
			// sessionStorage.setItem("active_index", this.index);
			console.log("跳转到我的粉丝");
			// window.location.href = "/h5/myFan.html?businessId=" + this.searchVideo.userId;
		},
		myAttention(){
			// sessionStorage.setItem("active_index", this.index);
			console.log("跳转到我的关注");
			// window.location.href = "/h5/myAttention.html?userId=" + this.searchVideo.userId;
		},
		//获取收藏的视频
		getConnectVideo(){
			const self = this
			anchorApi.getConnectVideo(self.connectVideo).then((res) => {
				console.log("this.connectVideo");
				console.log(res);
				self.loadingConnect = false
				self.connectVideo.totalPage = res.data.page.totalPage;
				self.connectVideo.totalCount = res.data.page.totalCount;
				self.connectVideo.page = res.data.page.currPage
				if (self.connectVideo.page == self.connectVideo.totalPage) {
					self.noMoreConnect = true
				}
				self.connectList = [...self.connectList, ...res.data.page.list];
				self.connectList.forEach((value, index, array) => {
					if (value.videoDuration) {
						value.videoDuration = value.videoDuration.slice(-8)
					}
				})
				// sessionStorage.setItem("connectList", JSON.stringify(self.connectList));
				// sessionStorage.setItem("connectVideo", JSON.stringify(self.connectVideo));
			})
		},
		getNewsList() {
			commonApi.getNews(this.newsSearch).then(res => {
				console.log("this.newsSearch");
				console.log(res);
				
				this.newsSearch.totalCount = res.data.page.totalCount;
				this.newsSearch.totalPage = res.data.page.totalPage;
				
				for (var i = 0; i < res.data.page.list.length; i++) {
					res.data.page.list[i].pictureUrl = res.data.page.list[i].pictureUrl.split(',')[0];
				}
				this.doSortNewsList(0, res.data.page.list);
				if(this.newsSearch.totalCount < this.newsSearch.limit){
					this.newsSearch.noMore = true;
				}
			})
		},
		doSortNewsList(index, list) {
			

			if (index < list.length) {
				uni.getSystemInfo({
					success: function(res) { // res - 各种参数
						var that = this
						 // console.log(res.windowHeight); // 屏幕的宽度
						  let info1 = uni.createSelectorQuery().select("#newsList2");// 获取某个元素
						  info1.boundingClientRect(function(data1){
							  that.newsHeight2 = data1.height
							  console.log("2的高度",data1.height);
						  }).exec()
						 let info = uni.createSelectorQuery().select("#newsList1");// 获取某个元素
						 info.boundingClientRect(function(data) { //data - 各种参数
							 that.newsHeight1 = data.height
							 console.log("获取的高度",data.height)  // 获取元素宽度
						 // that.heightHome = data.height;
						 }).exec()
					}.bind(this)
				});
				console.log(this.newsHeight1);
				console.log(this.newsHeight2);
				if (this.newsHeight1 <= this.newsHeight2) {
					this.newsList1.push(list[index]);
				} else {
					this.newsList2.push(list[index]);
				}
				let that = this;
				this.$nextTick(() => {
					setTimeout(() => {
						that.doSortNewsList(index + 1, list);
					}, 50);
				})
			}else{
				// sessionStorage.setItem("active_index", this.index);
				// sessionStorage.setItem("newsList1", JSON.stringify(this.newsList1));
				// sessionStorage.setItem("newsList2", JSON.stringify(this.newsList2));
				// sessionStorage.setItem("newsSearch", JSON.stringify(this.newsSearch));
			}
		},
		giveLike(id, index, dataType) {
			if (this.currentUser.type == 3) {
				uni.redirectTo({
				  url: '/pages/account/login/login'
				})
				// window.location.href = '/h5loginByCaptcha.html'
			} else {
				anchorApi.toCollect(this.currentUser.id,10,id).then((res) => {
					if (res.data.code == 0) {
						if (dataType == 1) {//左侧数据
							this.newsList1[index].like = 1;
							this.newsList1[index].likeCount = this.newsList1[index].likeCount + 1;
							this.newsList1[index].collectId = res.data.collection.id;
						} else {//右侧数据
							this.newsList2[index].like = 1;
							this.newsList2[index].likeCount = this.newsList2[index].likeCount + 1;
							this.newsList2[index].collectId = res.data.collection.id;
						}

					}
				})
			}
		},
		
		
		cancelLike(index, collectId, dataType) {
			anchorApi.cancelLike(collectId).then((res) => {
				if (res.data.code == 0) {
					if(dataType == 1){
						this.newsList1[index].like = 0;
						this.newsList1[index].likeCount = this.newsList1[index].likeCount - 1;
					}else{
						this.newsList2[index].like = 0;
						this.newsList2[index].likeCount = this.newsList2[index].likeCount - 1;
					}

				}
			})
		},
		editMsg(){
			uni.navigateTo({
				url:'/pages/person/updatePersonInfo'
			})
			
			// window.location.href = '/h5/personalInformation.html';
		},
		goNewsDet(id){
			// sessionStorage.setItem("active_index", this.index);
			uni.navigateTo({
				url: '/pages/product/imageTextimageText?id=' + id
			})
			// window.location.href = '/h5/news/newsDetail.html?id='+ id;
		},
		//视频点赞
		giveVideoLike(id, index){
			if(this.currentUser.type == 3){
				uni.redirectTo({
				  url: '/pages/account/login/login'
				})
				// window.location.href = '/h5loginByCaptcha.html'
			}else {
				anchorApi.toCollect(this.currentUser.id,5,id).then(res => {
					if (res.data.code == 0) {
						this.videoList[index].like = res.data.collection;
						this.videoList[index].likeCount++;
					}
				})
			}
		},
		//视频取消点赞
		cancelVideoLike(like, index){
			anchorApi.cancelLike(like.id).then(res => {
				if (res.data.code == 0) {
					this.videoList[index].like = null;
					this.videoList[index].likeCount--;
				}
			})
		}
	}
	
}
</script>

<style>
	.anchorHomepage .anchor-module {
	    background-color: #ffffff;
	    padding: 0px 28rpx 28rpx;
	    margin-top: -70rpx;
	    position: relative;
	    z-index: 1;
	    border-bottom: 28rpx solid #f5f5f9;
	}
	.anchorHomepage .anchor-module .anchor-total {
	    margin: 37rpx 0px 0px;
	}
	.anchorHomepage .anchor-module .anchor-info {
	    z-index: 5;
	    display: flex;
	    justify-content: space-between;
	    align-items: center;
	    flex-wrap: wrap;
	}
	.anchorHomepage .anchor-module .anchor-info .info {
	    align-items: flex-end;
		display: flex;
	}
	.anchorHomepage .anchor-module .anchor-info .info .avatar {
		height: 144rpx;
	    width: 144rpx;
	    margin-right: 18rpx;
	    margin-top: -35rpx;
	    border-radius: 18rpx;
	}
	.anchorHomepage .anchor-module .anchor-info .info .name-grey .h4 {
	    font-size: 17px;
	}
	.anchorHomepage .anchor-module .anchor-info .info .name-grey .p {
	    color: #8f99a7;
	    font-size: 11px;
		display: flex;
	}
	.anchorHomepage .anchor-module .anchor-info .info .name-grey image {
		height: 28rpx;
	    width: 28rpx;
	    margin-right: 9rpx;
	}
	.anchorHomepage .anchor-module .anchor-total  .div {
	    width: 20%;
	    text-align: center;
	}
	.anchorHomepage .anchor-module .anchor-total .div .h3 {
	    font-size: 16px;
	    font-weight: bold;
	}
	.anchorHomepage .anchor-module .anchor-total .div .p {
	    color: #8f99a7;
	    font-size: 11px;
	    margin-top: -7rpx;
	}
	.anchorHomepage .tabs {
	    line-height: 84rpx;
	    position: relative;
	}
	.connaught-style .tabs {
	    height: 93rpx;
	    justify-content: flex-start;
	    background-color: #ffffff;
	    position: fixed;
	    top: 0px;
	    left: 0px;
	    width: 100%;
	    z-index: 35;
	}
	.box-shadow, .connaught-style .tabs {
	    box-shadow: #ddd 0px 0px 37rpx;
	}
	.connaught-style .tabs .item.active {
	    color: #019d9d;
	}

	.anchorHomepage .tabs .item {
	    width: 33.3%;
	    position: relative;
	    font-size: 15px;
	}
	.connaught-style .tabs .item {
	    font-size: 15px;
	    text-align: center;
	    position: relative;
	}
	.anchorHomepage .tabs .item .strong {
	    color: #8f99a7;
	    font-size: 12px;
	}
	.connaught-style .tabs .item.active .span {
	    background-color: #019d9d;
	}
	.anchorHomepage .tabs .item .span {
	    bottom: -4rpx;
	}
	.connaught-style .tabs .item .span {
	    position: absolute;
	    left: 40%;
	    bottom: 0px; 
	    width: 20%;
	    height: 4rpx;
	    border-radius: 2rpx;
	    background-color: #ffffff;
	}
	#fall-list .fall-line {
	    float: left;
	    width: 50%;
	}
	#fall-list .fall-item {
	    width: 96%;
	    background-color: #fff;
	    border-radius: 11rpx;
	    overflow: hidden;
	}
	.item-title1 {
	    overflow: hidden;
	    text-overflow: ellipsis;
	    display: -webkit-box;
	    -webkit-line-clamp: 1;
	    -webkit-box-orient: vertical;
	    padding: 0px 19rpx;
	    /* line-height: 0.93rem; */
	    /* height: 0.93rem; */
	    color: #191919;
	    font-size: 13px;
	    -webkit-line-clamp: 2;
	    margin-top: 7rpx;
	}
	.play-comment1 {
	    justify-content: flex-start;
	    padding-bottom: 42rpx;
	}
	.play-comment1 view {
	    margin-left: 20rpx;
	    color: #8f99a7;
	    font-size: 11px;
	}
	.play-comment1 view image {
	    width: 24rpx;
	    height: 24rpx;
	    display: inline-block;
	    vertical-align: middle;
	    margin-right: 8rpx;
	    margin-top: -7rpx;
	}
	.connaught-style .sp-module {
	    padding: 14rpx 14rpx 0;
		display: flex;
		justify-content: space-between;
		align-items: center;
		flex-wrap: wrap;
	}
	.connaught-style .sp-module .item {
	    width: 48.5%;
	    background-color: #ffffff;
	    border-radius: 11rpx;
	    overflow: hidden;
	    margin-bottom: 14rpx;
	}
	.connaught-style .sp-module .item .item-image {
	    position: relative;
	    /* height: 3rem; */
	    overflow: hidden;
	    display: flex;
	    align-items: center;
	    background-color: #000;
	}
	.connaught-style .sp-module .item .item-image .date {
	    position: absolute;
	    width: 90rpx;
	    height: 40rpx;
	    line-height: 40rpx;
	    background-color: rgba(0,0,0,0.5);
	    font-size: 10px;
	    z-index: 33;
	    left: 0;
	    top: 0;
	    text-align: center;
	    color: #ffffff;
	    border-radius: 6px 0px 6px 0px;
	}
	.connaught-style .sp-module .item .item-title {
	    overflow: hidden;
	    text-overflow: ellipsis;
	    display: -webkit-box;
	    -webkit-line-clamp: 1;
	    -webkit-box-orient: vertical;
	    padding: 0px 19rpx;
	    line-height: 65rpx;
	    height: 65rpx;
	    color: #191919;
	    font-size: 13px;
	}
	.connaught-style .sp-module .item .play-comment {
	    justify-content: flex-start;
	    padding-bottom: 20rpx;
		display: flex;
	}
	.connaught-style .sp-module .item .play-comment view {
	    margin-left: 20rpx;
	    color: #8f99a7;
	    font-size: 11px;
	}
	.connaught-style .sp-module .item .play-comment view image {
		width: 24rpx;
		height: 24rpx;
		display: inline-block;
		vertical-align: middle;
		margin-right: 8rpx;
		margin-top: -7rpx;
	}
	.anchorHomepage .anchor-module .anchor-info .btn_a {
	    width: 149rpx;
	    height: 63rpx;
	    border-radius: 32rpx;
	    font-size: 14px;
	    border: 0px;
	    color: #fff;
	    justify-content: center;
	    color: #8f99a7;
	    background-color: #eaecee;
		text-align: center;
		line-height: 63rpx;
	}
	.anchorHomepage .anchor-module .anchor-info .btn {
	    width: 149rpx;
	    height: 63rpx;
	    border-radius: 32rpx;
	    background-color: #fc5260;
	    font-size: 14px;
	    border: 0px;
	    color: #fff;
	    justify-content: center;
		line-height: 63rpx;
		display: flex;
	}
	
</style>